UPDATE DataOperation SET LoadOrder = LoadOrder + 1 WHERE LoadOrder >= 7
INSERT INTO DataOperation VALUES('openXDA.MATLAB.dll', 'openXDA.MATLAB.MATLABAnalysisOperation', 7)

DECLARE @basePath VARCHAR(MAX) = 'D:\Apps\UTCAnalytics'

INSERT INTO MATLABAnalytic VALUES
(@basePath + '\AD_Clipping\for_redistribution_files_only\ad_clipping.dll', 'AD_Clipping', '', 1),
(@basePath + '\Blown_Fuse\for_redistribution_files_only\Blown_Fuse.dll', 'Blown_Fuse', '', 2),
(@basePath + '\Capacitor_Switching\for_redistribution_files_only\Capacitor_Switching.dll', 'Capacitor_Switching', '', 3),
(@basePath + '\CT_Saturation\for_redistribution_files_only\CT_Saturation.dll', 'CT_Saturation', '', 4),
(@basePath + '\CVT_Failure\for_redistribution_files_only\CVT_Failure.dll', 'CVT_Failure', '', 5),
(@basePath + '\DC_Offset\for_redistribution_files_only\DC_Offset.dll', 'DC_Offset', '', 6),
(@basePath + '\Ferroresonance\for_redistribution_files_only\Ferroresonance.dll', 'Ferroresonance', '', 7),
(@basePath + '\Harmonic_Resonance\for_redistribution_files_only\Harmonic_Resonance.dll', 'Harmonic_Resonance', '', 8),
(@basePath + '\HS_Reclosing\for_redistribution_files_only\HS_Reclosing.dll', 'HS_Reclosing', '', 9),
(@basePath + '\Lightning\for_redistribution_files_only\Lightning.dll', 'Lightning', '', 10),
(@basePath + '\Motor_Starting\for_redistribution_files_only\Motor_Starting.dll', 'Motor_Starting', '', 11),
(@basePath + '\Transient_Noise\for_redistribution_files_only\Transient_Noise.dll', 'Transient_Noise', '', 12),
(@basePath + '\VFD_Starting\for_redistribution_files_only\VFD_Starting.dll', 'VFD_Starting', '', 13),
(@basePath + '\VT_Grounding\for_redistribution_files_only\VT_Grounding.dll', 'VT_Grounding', '', 14)

UPDATE MATLABAnalytic SET SettingSQL =
'SELECT ' +
'60 frequency, ' +
'15 ct_saturation_serviceFactor, ' +
'14 ct_saturation_serviceFactorAD, ' +
'3 ct_saturation_offsetRatio, ' +
'2 ct_saturation_preEvent, ' +
'5 ct_saturation_derivRatio, ' +
'10 ct_saturation_zeroCrossThresh, ' +
'0.150000000000000 ct_saturation_secHarmMin, ' +
'0.600000000000000 ct_saturation_secHarmMax, ' +
'0.050000000000000 ct_saturation_thirdHarmMin, ' +
'0.600000000000000 ct_saturation_thirdHarmMax, ' +
'4 ad_clipping_repeatedSamples, ' +
'10 ad_clipping_window_size, ' +
'10 ad_clipping_zeroThresh, ' +
'10 ad_clipping_tolerance, ' +
'1 ferroresonance_preEvent, ' +
'5 ferroresonance_cycleThresh, ' +
'5 ferroresonance_numChanges, ' +
'0.500000000000000 ferroresonance_changeThresh, ' +
'50 ferroresonance_maxHarm, ' +
'0.050000000000000 ferroresonance_harmonicThresh, ' +
'5000 ferroresonance_zeroVoltThresh, ' +
'20 ferroresonance_zeroCurrentThresh, ' +
'0.300000000000000 ferroresonance_currentDiff, ' +
'0.080000000000000 harmonic_resonance_thd_thresh, ' +
'5 harmonic_resonance_minHarmonic, ' +
'0.050000000000000 harmonic_resonance_harmThresh, ' +
'100 harmonic_resonance_numberHarmonics, ' +
'0.100000000000000 harmonic_resonance_diffChangeRatio, ' +
'3 harmonic_resonance_numCyclesThresh, ' +
'2 induced_transient_noise_preEvent, ' +
'5 induced_transient_noise_numSpikes, ' +
'1.100000000000000 induced_transient_noise_spikeThresh, ' +
'10 induced_transient_noise_derivRatio, ' +
'20 induced_transient_noise_suddenChangesThresh, ' +
'5 induced_transient_noise_cycleSpan, ' +
'0.250000000000000 induced_transient_noise_cyclesBtwnSpikes, ' +
'30 induced_transient_noise_nomDiffRatio, ' +
'20 induced_transient_noise_harmNum, ' +
'0.050000000000000 induced_transient_noise_maxHarmRatio, ' +
'2 hs_reclosing_preEvent, ' +
'0.500000000000000 hs_reclosing_window, ' +
'0.010000000000000 hs_reclosing_zeroThreshold, ' +
'0.500000000000000 hs_reclosing_decayThresh, ' +
'0.100000000000000 hs_reclosing_sagThresh, ' +
'0.300000000000000 hs_reclosing_stepUpThresh, ' +
'0.500000000000000 hs_reclosing_stepDownThresh, ' +
'0.100000000000000 hs_reclosing_minDeadTime, ' +
'0.500000000000000 dc_offset_fftRatio, ' +
'0.500000000000000 dc_offset_magRatio, ' +
'2 dc_offset_preEvent, ' +
'30 dc_offset_zeroThresh, ' +
'2 motor_starting_preEvent, ' +
'0.950000000000000 motor_starting_sagThresh, ' +
'2 motor_starting_spikeThresh, ' +
'10 motor_starting_cycleSpan, ' +
'0.150000000000000 motor_starting_VharmThresh, ' +
'0.150000000000000 motor_starting_IharmThresh, ' +
'15 motor_starting_harmonicNum, ' +
'8 vfd_start_numCycles, ' +
'0.500000000000000 vfd_start_currentDip, ' +
'5 vfd_start_harmRatio, ' +
'0.500000000000000 blown_fuse_preEvent, ' +
'2 blown_fuse_faultThresh, ' +
'0.500000000000000 blown_fuse_tolerance, ' +
'0.020000000000000 blown_fuse_secondDiffRatio, ' +
'0.250000000000000 blown_fuse_minCycles, ' +
'0.950000000000000 blown_fuse_nearPeak, ' +
'0.500000000000000 blown_fuse_faultEndThresh, ' +
'1.500000000000000 blown_fuse_maxCycles, ' +
'50 blown_fuse_minCurrent, ' +
'1 capacitor_switching_preEvent, ' +
'2 capacitor_switching_maxCycles, ' +
'1.020000000000000 capacitor_switching_overVolt, ' +
'1.100000000000000 capacitor_switching_highThresh, ' +
'0.150000000000000 capacitor_switching_tolerance, ' +
'0.100000000000000 capacitor_switching_peakTolerance, ' +
'0.020000000000000 capacitor_switching_diffThresh, ' +
'0.900000000000000 capacitor_switching_dipThresh, ' +
'1 lightning_preEvent, ' +
'5 lightning_minDiffChange, ' +
'0.020000000000000 lightning_diffFromNominal, ' +
'0.100000000000000 lightning_disturbanceGap, ' +
'0.100000000000000 lightning_disturbLength, ' +
'1 lightning_maxCycles, ' +
'5 lightning_maxStrikes, ' +
'1 vt_grounding_preEvent, ' +
'1.050000000000000 vt_grounding_swellThresh, ' +
'0.950000000000000 vt_grounding_sagThresh, ' +
'5 vt_grounding_phaseTolerance, ' +
'1 incipient_cvt_failure_preEvent, ' +
'1.100000000000000 incipient_cvt_failure_overVoltThresh, ' +
'0.900000000000000 incipient_cvt_failure_lowVoltThresh, ' +
'0.250000000000000 incipient_cvt_failure_durationThresh, ' +
'3 incipient_cvt_failure_cycleThresh, ' +
'0.020000000000000 incipient_cvt_failure_VmeanRatio, ' +
'0.050000000000000 incipient_cvt_failure_ImeanRatio, ' +
'100 incipient_cvt_failure_zeroCurrentThresh, ' +
'1200 ct_primary'